package com.cmcc.aregister.ui.activity;

import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.cmcc.aregister.R;
import com.cmcc.aregister.cs.asntask.InterfaceUtils.DataCallback_cancel_other_order;
import com.cmcc.aregister.cs.asntask.MyAsynaTask;
import com.cmcc.aregister.cs.constant.Arguments;
import com.cmcc.aregister.cs.constant.ConfigUtilHelper;
import com.cmcc.aregister.cs.constant.GlobalSetting;
import com.cmcc.aregister.cs.constant.HelpInc;
import com.cmcc.aregister.cs.constant.XmlResolve;
import com.cmcc.aregister.cs.http.HttpAsyncTask;
import com.cmcc.aregister.cs.model.Appointment;
import com.cmcc.aregister.cs.model.CandelOrderResultModel;
import com.cmcc.aregister.cs.model.FamilyModel;
import com.cmcc.aregister.cs.model.MemberModel;
import com.cmcc.aregister.cs.model.OrderInfoModel;
import com.cmcc.aregister.cs.model.OrderModel;
import com.cmcc.aregister.cs.model.PayTypeModel;
import com.cmcc.aregister.cs.model.QuickYuyueEntity;
import com.cmcc.aregister.cs.model.Schedule;
import com.cmcc.aregister.cs.util.PotoalParcelable;
import com.cmcc.aregister.cs.util.Utils;
import com.cmcc.aregister.ui.adapter.ServiceAdapter;
import com.cmcc.aregister.ui.dialog.QuickYuyueDlg;
import com.cmcc.aregister.ui.dialog.QuickYuyueMemberDlg;
import com.cmcc.aregister.ui.dialog.QuickYuyueTimeDlg;
import com.cmcc.aregister.ui.view.LinearLayoutForListView;
import com.oauth.utils.EncryptUtils;
import com.unionpay.upomp.bypay.util.UPOMP;

/**
 * 订单详情
 * 
 * @author ld
 * 
 */
public class AppDetailActivity extends ParentActivity implements HelpInc,
    DataCallback_cancel_other_order
{
    // ------view------
    private final static String TAG = "AppDetailActivity";
    private Button app_btn, payBtn, payAgain;

    // ------parameter------
    private String user_name;
    private String other_order_fee;
    private String user_mobile;
    private String other_order_time;
    private LinearLayoutForListView service_list;

    private int type;
    private int title_str;
    private String name;
    private String chn_name;
    private String unit_name;
    private String unit_id;
    private String dep_name;
    private String doctor_name;
    private String guahao_amt;
    private String time;
    private String time_begin;
    private String time_end;
    private String app_id;
    private String order_no;
    private int status;
    private int pay_status;
    private String reservationType;
    private String serviceSumPrice;
    private int position;
    private Appointment mAppointment;
    MyAsynaTask asnTask;
    private List<MemberModel> members;

    // ------------

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        init(R.layout.p_app_detail);
    }

    @Override
    protected void setupData()
    {
        Map<String, Object> httpMap = ((PotoalParcelable) getIntent()
            .getParcelableExtra(Arguments.INTENT_TO_NEXT_PAGE)).map;
        type = (Integer) httpMap.get(Arguments.ACTIVITY_JUMP_TYPE);
        if (type == 0)
        {
            title_str = R.string.local_appointment;
            guahao_amt = (String) httpMap
                .get(Arguments.ACTIVITY_JUMP_GUAHAO_AMT);
            unit_id = (String) httpMap.get(Arguments.ACTIVITY_JUMP_UNIT_ID);
            findViewById(R.id.local_layout).setVisibility(View.VISIBLE);
        }
        else
        {
            title_str = R.string.other_appointment;
            findViewById(R.id.other_layout).setVisibility(View.VISIBLE);
            pay_status = Integer.parseInt((String) httpMap
                .get(Arguments.ACTIVITY_JUMP_PAY_STATUS));
            reservationType = (String) httpMap
                .get(Arguments.ACTIVITY_JUMP_RESERVATION_TYPE);
            serviceSumPrice = (String) httpMap
                .get(Arguments.ACTIVITY_JUMP_SERVICE_SUM_PRICE);
        }

        user_name = (String) httpMap.get(Arguments.ACTIVITY_JUMP_USER_NAME);
        user_mobile = (String) httpMap.get(Arguments.ACTIVITY_JUMP_USER_MOBILE);
        other_order_time = (String) httpMap
            .get(Arguments.ACTIVITY_JUMP_OTHER_ORDER_TIME);
        other_order_fee = (String) httpMap
            .get(Arguments.ACTIVITY_JUMP_OTHER_ORDER_FEE);

        name = (String) httpMap.get(Arguments.ACTIVITY_JUMP_NAME);
        chn_name = (String) httpMap.get(Arguments.ACTIVITY_JUMP_CHN_NAME);
        unit_name = (String) httpMap.get(Arguments.ACTIVITY_JUMP_HOSPITAL);
        dep_name = (String) httpMap.get(Arguments.ACTIVITY_JUMP_DEPARTMENT);
        doctor_name = (String) httpMap.get(Arguments.ACTIVITY_JUMP_DOCTOR);
        time = (String) httpMap.get(Arguments.ACTIVITY_JUMP_CHOICE_TIME);
        time_begin = (String) httpMap
            .get(Arguments.ACTIVITY_JUMP_CHOICE_TIME_BEGIN);
        time_end = (String) httpMap
            .get(Arguments.ACTIVITY_JUMP_CHOICE_TIME_END);
        app_id = (String) httpMap.get(Arguments.ACTIVITY_JUMP_DETL_ID);
        order_no = (String) httpMap.get(Arguments.ACTIVITY_JUMP_ORDER_NO);
        status = Integer.parseInt((String) httpMap
            .get(Arguments.ACTIVITY_JUMP_STATUS));

        position = (Integer) httpMap.get(Arguments.ACTIVITY_JUMP_POSITION);
        mAppointment = (Appointment) httpMap.get(Arguments.ACTIVITY_JUMP_APP);
        app_btn = (Button) findViewById(R.id.app_btn);
        payBtn = (Button) findViewById(R.id.pay_btn);
        payAgain = (Button) findViewById(R.id.pay_again_btn_detail);
    }

    /**
     * 初始化异地订单详情界面
     */
    private void initOtherView()
    {
        ((TextView) findViewById(R.id.order_no)).setText(Utils
            .getOtherDesc(app_id));
        ((TextView) findViewById(R.id.other_unit_name)).setText(Utils
            .getOtherDesc(unit_name));
        ((TextView) findViewById(R.id.other_dep_name)).setText(Utils
            .getOtherDesc(dep_name));
        ((TextView) findViewById(R.id.other_doctor_name)).setText(Utils
            .getOtherDesc(doctor_name));
        ((TextView) findViewById(R.id.other_time)).setText(Utils
            .getOtherDesc(other_order_time));
        ((TextView) findViewById(R.id.other_status)).setText(Utils
            .getOtherStatus(status + ""));
        ((TextView) findViewById(R.id.other_pay_status)).setText(Utils
            .getOtherPaystatus(pay_status + ""));
        ((TextView) findViewById(R.id.other_order_time)).setText(Utils
            .getOtherDesc(time));
        ((TextView) findViewById(R.id.user_name)).setText(Utils
            .getOtherDesc(user_name));
        ((TextView) findViewById(R.id.user_mobile)).setText(Utils
            .getOtherDesc(user_mobile));
        ((TextView) findViewById(R.id.other_order_fee)).setText(Utils
            .getOtherDesc(other_order_fee) + "元");
        ((TextView) findViewById(R.id.reservation_type)).setText(Utils
            .getReservationType(reservationType));
        service_list = (LinearLayoutForListView) findViewById(R.id.service_list);
        if (reservationType.equals("0"))
        {
            ((LinearLayout) findViewById(R.id.service_sum_price_view))
                .setVisibility(View.GONE);
            service_list.setVisibility(View.GONE);
        }
        ((TextView) findViewById(R.id.service_sum_price))
            .setText(serviceSumPrice + "元");
        if (status == 0 || status == 8 || status == 9)
        {
            // app_btn.setVisibility(View.VISIBLE);
            app_btn.setText(getString(R.string.cancel_app));
            payBtn.setVisibility(View.GONE);
        }
    }

    @Override
    protected void setupView()
    {
        // ((TextView) findViewById(R.id.title)).setText(title_str);
        if (type == 0)
        {
            ((TextView) findViewById(R.id.name)).setText(name);
            ((TextView) findViewById(R.id.chn_name)).setText(chn_name);
            ((TextView) findViewById(R.id.unit_name)).setText(unit_name);
            ((TextView) findViewById(R.id.dep_name)).setText(dep_name);
            ((TextView) findViewById(R.id.doctor_name)).setText(doctor_name);
            ((TextView) findViewById(R.id.time)).setText(time + " ("
                + time_begin + "-" + time_end + ")");
            ((TextView) findViewById(R.id.guahao_amt)).setText(guahao_amt
                + getString(R.string.yuan_txt));
            ((TextView) findViewById(R.id.status)).setText(Utils
                .getStatus(status + ""));
            if (status == 1)
            {// 预约成功或者爽约
             // app_btn.setVisibility(View.VISIBLE);
                app_btn.setText(getString(R.string.cancel_app));
                // payBtn.setVisibility(View.VISIBLE);屏蔽在线小额支付-20121015
                payBtn.setVisibility(View.GONE);
                // payAgain.setVisibility(View.VISIBLE);
                payAgain.setText(R.string.pay_again);
            }
            else if (status == 3)
            {
                // app_btn.setVisibility(View.VISIBLE);
                app_btn.setText(getString(R.string.cancel_app));
                payBtn.setVisibility(View.GONE);
            }
            else if (status == -1)
            {// 已经取消
             // app_btn.setVisibility(View.VISIBLE);
                app_btn.setText(getString(R.string.again_order));
                payBtn.setVisibility(View.GONE);
            }
        }
        else
        {
            showProgressDialog();
            getOtherOrderInfo(app_id);
        }
        app_btn = (Button) findViewById(R.id.app_btn);

        app_btn.setOnClickListener(onClickListener);

        payBtn = (Button) findViewById(R.id.pay_btn);
        payBtn.setOnClickListener(onClickListener);
        payAgain.setOnClickListener(onClickListener);
    }

    OnClickListener onClickListener = new OnClickListener() {

        @Override
        public void onClick(View v)
        {
            int id = v.getId();
            if (id == R.id.app_btn)
            {
                if (type == 0)
                {
                    if (app_btn.getText().toString()
                        .equals(getString(R.string.cancel_app)))
                    {// 取消预约
                        sendCancelAppointmentTask(
                            ConfigUtilHelper.getMobile(app), unit_id, app_id);
                    }
                    else
                    {// 再次预约
                        sendQuickAppointmentTask();
                    }
                }
                else
                {
                    // sendCancelOtherOrder(app_id);
                    showProgressDialogNew(R.string.dialog_loading_order_cancel);
                    cancelOtherOrder(ConfigUtilHelper.getMobile(app), app_id);
                }
            }
            else if (id == R.id.pay_btn)
            {
                showAlertDlg_card(getString(R.string.pay_type_title),
                    getString(R.string.dialog_yes),
                    getString(R.string.pay_a_moment));
                // showAlertDlg(getString(R.string.notice),getString(R.string.dlg_pay_confirm_msg),getString(R.string.dlg_yes),getString(R.string.dlg_no));
            }
            else if (id == R.id.pay_again_btn_detail)
            {
                getPayTypeTask(unit_id);
            }
        }
    };

    /**
     * 获取医院的支付方式(再次支付)
     */
    private HttpAsyncTask getPayTypeTask;

    /**
     * 根据医院的ID获取支付方式（再次支付）
     * 
     * @param unit_id
     */
    private void getPayTypeTask(String unit_id)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("unit_id", unit_id);
        parameterMap.put("mobile", ConfigUtilHelper.getMobile(app));
        String changeUserInfoUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_HOSPITAL_PAY_TYPE, parameterMap);
        getPayTypeTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_GET_HOSPITAL_PAY_TYPE_INFO, changeUserInfoUrl,
            HttpAsyncTask.CACHE_TYPE_ACTION, false);
        showProgressDialogNew(R.string.get_pay_type_tips);
        getPayTypeTask.setUIHandler(getPayTypeTaskHandler);
        mHttpManager.execute(getPayTypeTask);
    }

    Handler getPayTypeTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                if (msg.obj != null)
                {
                    Map<String, Object> map = (Map<String, Object>) msg.obj;
                    ArrayList<PayTypeModel> paytypes = (ArrayList<PayTypeModel>) map
                        .get(Arguments.XML_PAYTYPE_LIST);
                    newButton(paytypes);
                    dismissProgressDialog();
                }
                else
                {
                    dismissProgressDialog();
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        };
    };
    private PopupWindow popupWindow;
    private int screenWidth;
    private int screenHeight;

    private void newButton(ArrayList<PayTypeModel> paytypes)
    {
        if (null != popupWindow)
        {
            popupWindow.dismiss();
            popupWindow = null;
            return;
        }
        else
        {
            int index = 0;
            View popupWindowView = getLayoutInflater().inflate(
                R.layout.paytype_popwindow, null, false);
            LinearLayout paytypelLinearLayout = (LinearLayout) popupWindowView
                .findViewById(R.id.paytype_btn);
            screenWidth = getWindowManager().getDefaultDisplay().getWidth();
            screenHeight = getWindowManager().getDefaultDisplay().getHeight();
            int h = (int) (screenHeight / 2.15);
            for (PayTypeModel type : paytypes)
            {
                Button codeBtn = new Button(this);
                setBtnAttribute(codeBtn, type.cfg_value, index);
                paytypelLinearLayout.addView(codeBtn);
                codeBtn.setTag(type.cfg_code);
                index++;
            }
            Button cancelBtn = new Button(this);
            cancelBtn.setText(R.string.logout_no);
            cancelBtn.setBackgroundResource(R.drawable.weibo_btn);
            cancelBtn.setTextSize(18);
            // RelativeLayout.LayoutParams rlp = new
            // RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT,60);
            // cancelBtn.setLayoutParams(rlp);
            cancelBtn.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v)
                {
                    popupWindowClose();
                }
            });
            paytypelLinearLayout.addView(cancelBtn);
            popupWindow = new PopupWindow(popupWindowView, screenWidth, h, true);
            popupWindow.setFocusable(true);
            popupWindow.setAnimationStyle(R.style.PopupAnimation);
            popupWindow.showAtLocation(findViewById(R.id.app_detail_parent),
                Gravity.BOTTOM, 0, 0);
            popupWindow.update();
        }
    }

    private void setBtnAttribute(Button codeBtn, String btnContent, int id)
    {
        codeBtn.setText(btnContent);
        codeBtn.setId(id);
        codeBtn.setBackgroundResource(R.drawable.weibo_btn);
        codeBtn.setTextSize(18);
        // RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
        // LayoutParams.WRAP_CONTENT,60);
        // codeBtn.setLayoutParams(rlp);
        codeBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v)
            {
                // 再次支付
                String payType = (String) v.getTag();
                // 如果选择银联支付
                if ("21".equals(payType))
                {
                    checkIsBind();
                }
                else
                {
                    payAgainAsyncTask("8", "wxcityMobileClient", app_id,
                        order_no, payType);
                }
                popupWindowClose();
            }
        });
    }

    /**
     * 再次支付
     */
    private HttpAsyncTask payAgainAsyncTask;

    private void payAgainAsyncTask(String cid, String token, String yuyue_id,
        String order_no, String pay_type)
    {
        String params = "cid=8&token=wxcityMobileClient&pay_method=" + pay_type
            + "&yuyueid=" + yuyue_id + "&order_no=" + order_no;
        payAgainAsyncTask = new HttpAsyncTask(HttpAsyncTask.POST,
            GlobalSetting.XML_GET_PAYAGAIN, Arguments.PAY_AGAIN_URL, params,
            HttpAsyncTask.CACHE_TYPE_ACTION, true);
        payAgainAsyncTask.setUIHandler(payAgainHandler);
        showProgressDialogNew(R.string.dialog_loading_pay_again);
        mHttpManager.execute(payAgainAsyncTask);
    }

    Handler payAgainHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------payAgainHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                    // String status = (String)
                    // httpMap.get(Arguments.XML_STATUS);
                    String message = (String) httpMap
                        .get(Arguments.XML_MESSAGE);
                    showSingleAlertDlg(getString(R.string.notice), message,
                        getString(R.string.close));
                }
                else
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.pay_again_fail),
                        getString(R.string.close));
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        }
    };

    private String params = "";
    private HttpAsyncTask queryBindCardTask;

    private void checkIsBind()
    {
        params = "cid=8&token=wxcityMobileClient&mid="
            + ConfigUtilHelper.getMobile(app);
        queryBindCardTask = new HttpAsyncTask(HttpAsyncTask.POST,
            GlobalSetting.XML_GET_BINDCARD, Arguments.CHECK_BIND_URL, params,
            HttpAsyncTask.CACHE_TYPE_ACTION, true);
        showProgressDialogNew(R.string.check_bind_info_tips);
        queryBindCardTask.setUIHandler(queryBindCardTaskHandler);
        mHttpManager.execute(queryBindCardTask);
    }

    private Handler queryBindCardTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    Map<String, Object> map = (Map<String, Object>) msg.obj;
                    String status = (String) map.get(Arguments.XML_STATUS);
                    if (!status.equals("1"))
                    {
                        showAlertDlg_UnionPay(getString(R.string.notice),
                            getString(R.string.payagain_suer_msg),
                            getString(R.string.dialog_yes),
                            getString(R.string.pay_a_moment));
                    }
                    else
                    {
                        payAgainAsyncTask("8", "wxcityMobileClient", app_id,
                            order_no, "21");
                    }
                }
                else
                {
                    showMsg(R.string.read_member_fail);
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.get_bind_info_err),
                    getString(R.string.close));
                break;
            }
        };
    };

    // 关闭弹出层
    private void popupWindowClose()
    {
        popupWindow.dismiss();
        popupWindow = null;
    }

    /**
     * 银联绑定支付
     * @param title
     * @param msg
     * @param posTitle
     * @param nagativeTitle
     */
    public void showAlertDlg_UnionPay(String title, String msg,
        String posTitle, String nagativeTitle)
    {
        new AlertDialog.Builder(this)
            .setTitle(title)
            .setMessage(msg)
            .setIcon(android.R.drawable.ic_dialog_info)
            .setCancelable(false)
            .setPositiveButton(posTitle, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which)
                {
                    addBankCardActivity();
                }
            })
            .setNegativeButton(nagativeTitle,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                    }
                }).create().show();
    }

    /**
     * 快速预约
     */
    private HttpAsyncTask sendQuickAppointmentTask;

    private void sendQuickAppointmentTask()
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("mobile", ConfigUtilHelper.getMobile(app));
        parameterMap.put("unit_name", mAppointment.unit_name);
        parameterMap.put("dep_name", mAppointment.dep_name);
        parameterMap.put("doctor_name", mAppointment.doctor_name);
        parameterMap.put("unit_id", mAppointment.unit_id);
        parameterMap.put("dep_id", mAppointment.dep_id);
        parameterMap.put("doctor_id", mAppointment.doctor_id);
        parameterMap.put("phone", mAppointment.phone);
        parameterMap.put("truename", mAppointment.truename);
        parameterMap.put("clinic_no", mAppointment.clinic_no);
        parameterMap.put("zcname", mAppointment.zcname);
        String getQuickUrl = Utils.changeUrl(Arguments.SERVER_URL_QUICK_YUYUE,
            parameterMap);
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "快速预约url：" + getQuickUrl);
        }
        sendQuickAppointmentTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_QUICK_ORDER, getQuickUrl,
            HttpAsyncTask.CACHE_TYPE_ACTION, true);
        sendQuickAppointmentTask.setUIHandler(sendQuickHandler);
        showProgressDialog();
        mHttpManager.execute(sendQuickAppointmentTask);
    }

    /**
     * 取消本地预约订单
     */
    private HttpAsyncTask sendCancelAppointmentTask;

    /**
     * 
     * @param mobile 手机号码
     * @param unit_id 医院ID
     * @param yuyue_id 订单ID
     */
    private void sendCancelAppointmentTask(String mobile, String unit_id,
        String yuyue_id)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("client_auth", "test");
        parameterMap.put("token", "123456");
        String str = "mobile=" + mobile + "&yuyue_id=" + yuyue_id + "&type="
            + 2 + "&unit_id=" + unit_id;
        String entryStr = "";
        try
        {
            entryStr = EncryptUtils.encode(str);
            entryStr = URLEncoder.encode(entryStr, "UTF-8");
        }
        catch (Exception e)
        {
            Log.i(TAG, "取消本地预约订单参数加密出现错误");
        }
        parameterMap.put("s", entryStr);
        String params = Utils.getParams(parameterMap);
        sendCancelAppointmentTask = new HttpAsyncTask(HttpAsyncTask.POST,
            GlobalSetting.XML_CANCEL_APPOINTMENT,
            Arguments.SERVER_URL_CANCEL_APPOINTMENT, params,
            HttpAsyncTask.CACHE_TYPE_ACTION, true);
        sendCancelAppointmentTask.setUIHandler(sendCancelHandler);
        showProgressDialogNew(R.string.dialog_loading_order_cancel);
        mHttpManager.execute(sendCancelAppointmentTask);
    }

    /**
     * 初始化参数
     * 
     * @param parameterMap
     * @return
     */
    private Map<String, String> initArgMap(Map<String, String> parameterMap)
    {
        parameterMap.put("userId", Arguments.userId);
        parameterMap.put("timestamp", ConfigUtilHelper.getStringNow());
        parameterMap.put("userPwd", ConfigUtilHelper.getUserPwd());
        return parameterMap;
    }

    /**
     * 获取异地订单详情
     * 
     * @param orderId
     */
    private void getOtherOrderInfo(String orderId)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("methodVit", Arguments.GetOrderInfo);
        parameterMap.put("orderNo", app_id);
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_ORDER_INFO,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 异地订单取消
     */
    private void cancelOtherOrder(String mobile, String orderNo)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("methodVit", Arguments.CancelOrder);
        parameterMap.put("mobile", mobile);
        parameterMap.put("orderNo", orderNo);
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_CANCEL_OTHER_ORDER,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 异地就医订单取消
     */
    private HttpAsyncTask sendCancelOtherOrder;

    /**
     * 
     * @param order_no 订单编号
     */
    private void sendCancelOtherOrder(String order_no)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("order_no", order_no);
        String cancelOtherOrderUrl = Utils.changeUrl(
            Arguments.SERVER_URL_CANCEL_OTHER_ORDER, parameterMap);
        sendCancelOtherOrder = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_CANCEL_OTHER_ORDER, cancelOtherOrderUrl,
            HttpAsyncTask.CACHE_TYPE_ACTION, true);
        sendCancelOtherOrder.setUIHandler(sendCancelHandler);
        showProgressDialog();
        mHttpManager.execute(sendCancelOtherOrder);
    }

    Handler sendCancelHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendCancelOtherOrderHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                    String status = (String) httpMap.get(Arguments.XML_STATUS);
                    String message = (String) httpMap
                        .get(Arguments.XML_MESSAGE);
                    if ("0".equals(status))
                    {
                        app.cancelApp(type, position);
                        if (can_show_dlg)
                        {
                            showInfoDialog(message,
                                new DialogInterface.OnClickListener() {

                                    @Override
                                    public void onClick(DialogInterface dialog,
                                        int which)
                                    {
                                        finish();
                                    }
                                });
                        }
                    }
                    else
                    {
                        showSingleAlertDlg(getString(R.string.notice), message,
                            getString(R.string.close));

                    }
                }
                else
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.cancel_order_fail),
                        getString(R.string.close));
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        }
    };
    QuickYuyueEntity quick;
    QuickYuyueDlg dlg_mast;
    QuickYuyueMemberDlg dlg_member;
    private boolean can_show_mast = true;
    QuickYuyueTimeDlg dlg_sch;
    private boolean can_show_sch = true;
    private boolean can_show_dlg = true;
    /**
     * 再次预约请求处理结果handler
     */
    Handler sendQuickHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendCancelOtherOrderHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                    String status = (String) httpMap.get(Arguments.XML_STATUS);
                    String message = (String) httpMap
                        .get(Arguments.XML_MESSAGE);
                    quick = (QuickYuyueEntity) httpMap
                        .get(Arguments.XML_QUICK_DATA);
                    if ("0".equals(status))
                    {
                        app.cancelApp(type, position);
                        if (can_show_mast)
                        {
                            dlg_mast = new QuickYuyueDlg(
                                AppDetailActivity.this, quick.mMastEntity,
                                AppDetailActivity.this);
                            dlg_mast.show();
                        }
                        /*
                         * showInfoDialog(message, new
                         * DialogInterface.OnClickListener() {
                         * 
                         * @Override public void onClick(DialogInterface dialog,
                         * int which) { finish(); } });
                         */
                    }
                    else
                    {

                        showSingleAlertDlg(getString(R.string.notice), message,
                            getString(R.string.close));

                    }
                }
                else
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.get_data_err),
                        getString(R.string.close));
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        }
    };

    /**
     * 进入小额支付（话费支付）
     */
    private void gotoPayWisite()
    {
        initUrl();
        String url = ConfigUtilHelper.payUrlPre + "?spID="
            + ConfigUtilHelper.spID + "&spPwd=" + ConfigUtilHelper.spPwd
            + "&spCode=" + ConfigUtilHelper.spCode + "&spType="
            + ConfigUtilHelper.spType + "&merchantCode="
            + ConfigUtilHelper.merchantCode + "&timestamp=" + timestamp
            + "&msg_id=" + msg_id + "&orderNo=" + orderNo + "&amount=" + amount
            + "&mobile=" + mobile + "&targetMobile=" + targetMobile
            + "&merchantName=" + ConfigUtilHelper.merchantName
            + "&merchandise=" + ConfigUtilHelper.merchandise + "&orderDesc="
            + ConfigUtilHelper.orderDesc + "&backUrl="
            + ConfigUtilHelper.backUrl + "&uid=" + uid + "&token=" + token
            + "&payType=" + ConfigUtilHelper.payType;
        if (ConfigUtilHelper.debug)
        {
            Log.i("AppDetailActivity", "url:" + url);
        }
        loadPayWebsite(url);
    }

    // 加载支付界面
    private void loadPayWebsite(String url)
    {
        Intent intent = new Intent(this, PayWebsite.class);
        intent.putExtra("url", url);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }

    /**
     * 小额支付提示框
     * 
     * @param title
     * @param msg
     * @param posTitle
     * @param nagativeTitle
     */
    public void showAlertDlg(String title, String msg, String posTitle,
        String nagativeTitle)
    {
        new AlertDialog.Builder(this)
            .setTitle(title)
            .setMessage(msg)
            .setIcon(android.R.drawable.ic_dialog_info)
            .setCancelable(true)
            .setPositiveButton(posTitle, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which)
                {
                    // TODO Auto-generated method stub
                    positiveDowork();
                }
            })
            .setNegativeButton(nagativeTitle,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                        // TODO Auto-generated method stub
                        nagativeDoWork();
                    }

                }).create().show();
    }

    private void positiveDowork()
    {
        gotoPayWisite();
        finish();
    }

    private void nagativeDoWork()
    {

    }

    RadioGroup radioGroup;
    RadioButton payTypeRadio01, payTypeRadio02;

    /**
     * 银联卡支付
     * 
     * @param title
     * @param posTitle
     * @param nagativeTitle
     */
    public void showAlertDlg_card(String title, String posTitle,
        String nagativeTitle)
    {
        LayoutInflater factory = LayoutInflater.from(this);
        final View view = factory.inflate(R.layout.sure_pay_view, null);
        payTypeRadio01 = (RadioButton) view.findViewById(R.id.pay_type01);
        payTypeRadio02 = (RadioButton) view.findViewById(R.id.pay_type02);
        payTypeRadio02.setChecked(true);
        radioGroup = (RadioGroup) view.findViewById(R.id.radiogroup);
        new AlertDialog.Builder(this)
            .setTitle(title)
            .setIcon(android.R.drawable.ic_dialog_info)
            .setCancelable(false)
            .setView(view)
            .setPositiveButton(posTitle, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which)
                {
                    // TODO Auto-generated method stub
                    if (payTypeRadio02.isChecked())
                    {
                        // positiveDoworkCard();
                        gotoPayWisite();
                    }
                    else
                    {
                        showSingleNoticeDlg(
                            getString(R.string.pay_order_locale),
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog,
                                    int which)
                                {
                                }
                            }).show();
                    }
                }
            })
            .setNegativeButton(nagativeTitle,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                        // TODO Auto-generated method stub
                    }

                }).create().show();
    }

    // private String testUrl =
    // "http://t.bypay.cn/wapGateWay/wap.order!plusMerPay.ac";
    /**
     * 进入银联卡支付界面
     * 
     */
    private void positiveDoworkCard()
    {
        showProgressDlgP(getString(R.string.notice),
            getString(R.string.logining_info));
    }

    private void initUrl()
    {
        orderNo = mAppointment.yuyue_id + ConfigUtilHelper.getStringNow();
        timestamp = ConfigUtilHelper.getStringNow();
        timeout = ConfigUtilHelper.getString10after();
        msg_id = ConfigUtilHelper.getMsgId();
        if (ConfigUtilHelper.debug)
        {
            guahao_amt = "0.01";
        }
        amount = guahao_amt;
        mobile = ConfigUtilHelper.getMobile(this);
        targetMobile = ConfigUtilHelper.getMobile(this);
        uid = ConfigUtilHelper.getUid(this);
        token = ConfigUtilHelper.getToken(this);
    }

    Intent intent = null;

    public void progressRunP()
    {
        String packageName = this.getPackageName(); // 得到安装包名称

        // 初始化手机POS环境
        com.unionpay.upomp.bypay.util.Utils.setPackageName(packageName);
        // MY_PKG是你项目的包名
        UPOMP.init();
        // 设置Intent指向AndroidManifest中设置的action
        // action的名字 改成（接入商名称_商户证书号_插件版本）例如 hanxin_303310048990001_2_0
        intent = new Intent(ConfigUtilHelper.payAction);
        // 将封装好的xml报文传入bundle
        Bundle mBundle = new Bundle();
        initUrl();
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "orderNo:" + orderNo);
        }
        String xml = ConfigUtilHelper.postXml(timestamp, timeout, msg_id,
            orderNo, amount, mobile, targetMobile);
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "xml:" + xml);
        }
        mBundle.putString("xml", xml);
        // xml（通过你的服务器获得）的格式（请阅读服务器） 示例： <?xml version="1.0" encoding="UTF-8" ?>
        /*
         * <upomp application="LanchPay.Req" version="1.0.0">
         * <merchantId>303310048990001</merchantId>
         * <merchantOrderId>20120216175424121305</merchantOrderId>
         * <merchantOrderTime>20120216175424</merchantOrderTime>
         * <sign>WQAU/lv3k1M4s6dBv0ge3CgzfXRgWhKn
         * +wlED1PYJQuC8sOJEC0tbPB54E4jFpHmkTryuogAxV5oqo1FEzHsRcWWIusfxhDW
         * /UvHsxGIPp2bNIfW5
         * kxFEPKkt/IfY9IoLOk9IvzoUOInPnwjBx9uA85wFWf2aR5h/csEQV9XHHQ=</sign>
         * </upomp>
         */
        // 如果你的activity关闭了，请设置pkg（插件返回要调起activity的action name），否则不需要写
        // mBundle.putString("pkg", "android.intent.action.MAIN");
        // 将bundle置于intent中
        intent.putExtras(mBundle);
        // 使用intent跳转至支付插件
    };

    public void doWorkP()
    {
        if (intent != null)
        {
            startActivity(intent);
            isGotoPay = true;
        }
    };

    private boolean isGotoPay = false;

    @Override
    protected void dismissProgressDialog()
    {
        // TODO Auto-generated method stub
        super.dismissProgressDialog();
    }

    @Override
    protected void onResume()
    {
        super.onResume();
        String status = null;
        String result = null;
        if (isGotoPay)
        {
            result = UPOMP.getPayResult();
            isGotoPay = false;
        }
        if (result != null)
        {
            // 解析result结果
            if (ConfigUtilHelper.debug)
            {
                Log.i(TAG, "--onResume--result:" + result);
            }

            try
            {
                status = XmlResolve.getResultInfoApi(result);
            }
            catch (Exception e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (status != null && status.equals("0000"))
            {
                showSingleAlertDlg_(getString(R.string.pay_success),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which)
                        {// 支付成功后关闭窗口进入支付管理页面
                         // TODO Auto-generated method stub
                            gotoAppManager();
                        }
                    }).show();
            }
            else
            {
                showSingleAlertDlg_(getString(R.string.pay_failed),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which)
                        {// 支付成功后关闭窗口进入支付管理页面
                         // TODO Auto-generated method stub
                        }
                    }).show();
            }
        }
        else
        {
            if (ConfigUtilHelper.debug)
            {
                Log.i(TAG, "--onResume--result == null");
            }
        }
    }

    private void gotoAppManager()
    {
        Intent intent = new Intent(AppDetailActivity.this,
            AppManagerActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        finish();
    }

    // 请求支付需要参数说明
    private String timestamp = "";// 提交时间戳yyyyMMddHHmmss
    private String timeout = "";// 支付超时时间
    private String msg_id = "";// 请求平台流水号,当前时间+4位随机数
    private String orderNo = "";// 订单号,当前时间+六位随机数
    private String amount = "";// 订单总金额
    private String mobile = "";// 手机号码
    private String targetMobile = "";// 接收号码
    private String uid = "";// 无线城市用户ID
    private String token = "";// 无线城市令牌

    private String[] content = { "", "", "", "" };

    @Override
    public void notifyUI(int position)
    {
        // getHospitalPayTypeTask(quick.unit_id);
        getFamily();
        // TODO Auto-generated method stub
        /*
         * Intent intent_1 = new Intent(AppDetailActivity.this,
         * OrderDetailActivity.class); Map<String, Object> httpMap = new
         * HashMap<String, Object>(); int currentTitleSelect = R.id.left_btn;
         * httpMap.put(Arguments.ACTIVITY_JUMP_AREA_TYPE, currentTitleSelect);
         * httpMap.put(Arguments.ACTIVITY_JUMP_UNIT_ID, quick.unit_id);
         * httpMap.put(Arguments.ACTIVITY_JUMP_DETL_ID,
         * scheduleList.get(position).detl_id); content[0] = quick.unit_name;
         * content[1] = quick.dep_name; content[2] = quick.doctor_name;
         * content[3] = scheduleList.get(position).begin_time + " - " +
         * scheduleList.get(position).end_time;
         * httpMap.put(Arguments.ACTIVITY_JUMP_ORDER_DETAIL, content);
         * httpMap.put
         * (Arguments.ACTIVITY_JUMP_GUAHAO_AMT,quick.mMastEntity.get(0
         * ).guahao_amt); PotoalParcelable potoal = new
         * PotoalParcelable(httpMap);
         * intent_1.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal);
         * intent_1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         * startActivity(intent_1);
         */
    }

    private void getFamily()
    {
        showProgressDialog();
        String params = "cid=8&token=wxcityMobileClient&phone="
            + ConfigUtilHelper.getMobile(app);
        sendGetFamilyTask = new HttpAsyncTask(HttpAsyncTask.POST,
            GlobalSetting.XML_GET_FAMILY_INFO, Arguments.GET_FAMILY_INFO_URL,
            params, HttpAsyncTask.CACHE_TYPE_ACTION, true);
        sendGetFamilyTask.setUIHandler(sendGetFamilyTaskHandler);
        mHttpManager.execute(sendGetFamilyTask);
    }

    /** 获取家庭成员信息 */
    private HttpAsyncTask sendGetFamilyTask;

    private Handler sendGetFamilyTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                    FamilyModel family = (FamilyModel) httpMap
                        .get(Arguments.XML_FAMILY_INFO);
                    if (family != null && family.members != null
                        && family.members.size() > 0)
                    {
                        members = family.members;
                    }
                    if (dlg_sch != null && dlg_sch.isShowing())
                    {
                        dlg_sch.dismiss();
                    }
                    /*
                     * dlg_member = new QuickYuyueMemberDlg(context,
                     * family.members, AppDetailActivity.this);
                     * dlg_member.show();
                     */
                    getHospitalPayTypeTask(quick.unit_id);
                }
                else
                {
                    showMsg(R.string.read_member_fail);
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.get_family_info_err),
                    getString(R.string.close));
                break;
            }
        };
    };

    /**
     * 获取医院的支付方式
     */
    private HttpAsyncTask getHospitalPayTypeTask;

    /**
     * 根据医院的ID获取支付方式
     * 
     * @param unit_id
     */
    private void getHospitalPayTypeTask(String unit_id)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("unit_id", unit_id);
        parameterMap.put("mobile", ConfigUtilHelper.getMobile(app));
        String changeUserInfoUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_HOSPITAL_PAY_TYPE, parameterMap);
        getHospitalPayTypeTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_GET_HOSPITAL_PAY_TYPE_INFO, changeUserInfoUrl,
            HttpAsyncTask.CACHE_TYPE_ACTION, false);
        showProgressDialogNew(R.string.get_pay_type_tips);
        getHospitalPayTypeTask.setUIHandler(getHospitalPayTypeTaskHandler);
        mHttpManager.execute(getHospitalPayTypeTask);
    }

    Handler getHospitalPayTypeTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                if (msg.obj != null)
                {
                    Map<String, Object> map = (Map<String, Object>) msg.obj;
                    Intent intent_1 = new Intent(AppDetailActivity.this,
                        OrderDetailActivity.class);
                    Map<String, Object> httpMap = new HashMap<String, Object>();
                    int currentTitleSelect = R.id.left_btn;
                    httpMap.put(Arguments.ACTIVITY_JUMP_AREA_TYPE,
                        currentTitleSelect);
                    httpMap.put(Arguments.ACTIVITY_JUMP_UNIT_ID, quick.unit_id);
                    httpMap.put(Arguments.ACTIVITY_JUMP_DETL_ID,
                        quick.mMastEntity.get(0).schedule_id);
                    content[0] = quick.unit_name;
                    content[1] = quick.dep_name;
                    content[2] = quick.doctor_name;
                    content[3] = scheduleList.get(position).begin_time + " - "
                        + scheduleList.get(position).end_time;
                    httpMap.put(Arguments.ACTIVITY_JUMP_ORDER_DETAIL, content);
                    httpMap.put(Arguments.ACTIVITY_JUMP_GUAHAO_AMT,
                        quick.mMastEntity.get(0).guahao_amt);
                    ArrayList<PayTypeModel> paytypeList = (ArrayList<PayTypeModel>) map
                        .get(Arguments.XML_PAYTYPE_LIST);
                    httpMap.put(Arguments.ACTIVITY_JUMP_PAY_TYPE_LIST,
                        paytypeList);
                    httpMap.put(Arguments.MEMBER_LIST, members);
                    PotoalParcelable potoal = new PotoalParcelable(httpMap);
                    intent_1.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal);
                    intent_1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent_1);
                }
                else
                {
                    dismissProgressDialog();
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        };
    };

    // private int allPage;
    private int currPage;
    private List<Schedule> scheduleList = new ArrayList<Schedule>();
    /**
     * 查询出诊班次的号源信息
     */
    private HttpAsyncTask sendGetScheduleListTask;

    /**
     * 
     * @param unit_id 医院ID
     * @param schedule_id 班次
     */
    private void sendGetScheduleListTask(String unit_id, String schedule_id)
    {
        logger.d("----------sendGetScheduleListTask----------");
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("unit_id", unit_id);
        parameterMap.put("schedule_id", schedule_id);
        String getScheduleListUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_SCHEDULE_LIST, parameterMap);
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "查询出诊班次地址：" + getScheduleListUrl);
        }
        sendGetScheduleListTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_SCHEDULE_LIST, getScheduleListUrl,
            HttpAsyncTask.CACHE_TYPE_SAVE, false);
        sendGetScheduleListTask.setUIHandler(sendGetScheduleListTaskHandler);
        showProgressDialog();
        mHttpManager.execute(sendGetScheduleListTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetScheduleListTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetScheduleListTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        List<Schedule> scheduleList_1 = (List<Schedule>) httpMap
                            .get(Arguments.XML_SCHEDULE_LIST);
                        scheduleList = scheduleList_1;
                        /*
                         * if (currPage == 1) { scheduleList = scheduleList_1; }
                         * else { scheduleList.addAll(scheduleList_1); }
                         */
                        if (dlg_mast != null && dlg_mast.isShowing())
                        {
                            dlg_mast.dismiss();
                        }
                        if (can_show_sch)
                        {
                            dlg_sch = new QuickYuyueTimeDlg(
                                AppDetailActivity.this, scheduleList,
                                AppDetailActivity.this);
                            dlg_sch.show();
                        }
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        // allPage = currPage;
                    }
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));

                // allPage = currPage;
                break;
            }
        }
    };

    /**
     * 通知寻找班次号源信息
     */
    @Override
    public void notifyUI(String msg)
    {
        // TODO Auto-generated method stub
        sendGetScheduleListTask(mAppointment.unit_id, msg);
    }

    @Override
    public void notifyUI(int msg, int position)
    {
        // TODO Auto-generated method stub

    }

    @Override
    protected void onDestroy()
    {
        // TODO Auto-generated method stub
        super.onDestroy();
        can_show_dlg = false;
        if (sendQuickHandler != null)
        {
            sendQuickHandler.removeCallbacks(sendQuickAppointmentTask);
            sendQuickHandler = null;
            can_show_mast = false;
        }
        if (sendGetScheduleListTaskHandler != null)
        {
            sendGetScheduleListTaskHandler
                .removeCallbacks(sendGetScheduleListTask);
            sendGetScheduleListTaskHandler = null;
            can_show_sch = false;
        }
    }

    /**
     * 取消订单回调函数（异地）
     * 
     * @param candelOrderResultModel
     */
    @Override
    public void cancel_other_order(CandelOrderResultModel candelOrderResultModel)
    {
        // TODO Auto-generated method stub
        dismissProgressDialog();
        if (candelOrderResultModel.resultCode.equals("000"))
        {
            app.cancelApp(1, position);
            app_btn.setVisibility(View.GONE);
            showInfoDialog(R.string.cancel_order_success,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                        finish();
                    }
                });
        }
        else if (candelOrderResultModel.resultCode.equals("002"))
        {
            if (candelOrderResultModel.resultMsg.equals(""))
            {
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.cancel_order_fail),
                    getString(R.string.close));
            }
            else
            {

                showSingleAlertDlg(getString(R.string.notice),
                    candelOrderResultModel.resultMsg, getString(R.string.close));
            }
        }
        else
        {
            showSingleAlertDlg(getString(R.string.notice),
                getString(R.string.cancel_order_fail),
                getString(R.string.close));
        }
    }

    @Override
    public void get_order_info(OrderInfoModel orderInfoModel)
    {
        // TODO Auto-generated method stub
        initOtherView();
        dismissProgressDialog();
        if (orderInfoModel.resultCode.equals("000"))
        {
            if (orderInfoModel.mOrderModel != null)
            {
                OrderModel orderModel = orderInfoModel.mOrderModel;
                String[] order_info = orderModel.orderDesc.split(" ");

                user_name = orderModel.userName;
                user_mobile = orderModel.mobile;
                time = orderModel.orderTime;

                unit_name = order_info[2];
                dep_name = order_info[3];
                doctor_name = order_info[4];
                if (order_info.length > 7)
                {
                    other_order_time = order_info[5] + " " + order_info[6]
                        + " " + order_info[7];
                }
                else
                {
                    other_order_time = order_info[5];
                }
                // time = orderModel.bestContactTime;
                other_order_fee = orderModel.orderFee;
                app_id = orderModel.orderNo;
                status = Integer.parseInt(orderModel.orderStatus);
                pay_status = Integer.parseInt(orderModel.payStatus);

                ServiceAdapter mServiceAdapter = new ServiceAdapter(
                    AppDetailActivity.this, orderModel.mServiceInfoModelList,
                    true);
                service_list.setAdapter(mServiceAdapter);
            }
        }
        else if (orderInfoModel.resultCode.equals("002"))
        {
            if (orderInfoModel.resultMsg.equals(""))
            {
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
            }
            else
            {
                showSingleAlertDlg(getString(R.string.notice),
                    orderInfoModel.resultMsg, getString(R.string.close));

            }
        }
        else
        {
            showSingleAlertDlg(getString(R.string.notice),
                getString(R.string.read_fail), getString(R.string.close));
        }

    }

    /**
     * 更新异地预约状态回调函数
     */
    @Override
    public void notifyUI_other(int msg, int position)
    {

    }

    /**
     * 获取异地班次信息回调函数（异地专家门诊快速预约的时候用到）
     */
    @Override
    public void notifyUI_other(String sch_id, String content)
    {

    }

    @Override
    public void notifyUI_member(MemberModel member)
    {
        // this.member = member;
        getHospitalPayTypeTask(quick.unit_id);
        dlg_member.dismiss();

    }

}